<template>
    <div class="top">
        <input type="text" v-model="title"><span>请输入用户名</span><br>
        <input type="text" v-model="age"><span>请输入年龄</span>&nbsp;&nbsp;
        <button @click="addInput()">提交</button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                title: '',
                age:'',
                inputList:[]
            }
        },
        methods: {
            addInput() {
                if ( this.title == '' || this.age == '') {
                    return alert('内容不能为空');
                }
                //声明组合对象
                let obj = {
                    name:this.title,
                    age:this.age,
                }
                this.inputList.push(obj)
                // console.log(this.inputList)
                this.$emit('sonSend',this.inputList);
            }
        },
        created () {
           
        },
        mounted () {
           
           
        },
    }
</script>

<style lang="scss">

</style>